package com.pearadmin.pro.modules.mkt.service.impl;

import java.util.List;
import java.util.ArrayList;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pearadmin.pro.common.web.base.page.PageResponse;
import com.pearadmin.pro.common.web.base.page.Pageable;

import com.pearadmin.pro.modules.mkt.domain.MktActive;
import com.pearadmin.pro.modules.mkt.domain.MktChannel;
import com.pearadmin.pro.modules.mkt.param.MktChannelRequest;
import com.pearadmin.pro.modules.mkt.repository.MktChannelRepository;
import com.pearadmin.pro.modules.mkt.service.MktChannelService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;


/**
 * 市场渠道管理
Service业务层处理
 *
 * @author chenJian
 * @date 2021-09-09
 */
@Service
public class MktChannelServiceImpl extends ServiceImpl<MktChannelRepository, MktChannel> implements MktChannelService
{
    @Resource
    private MktChannelRepository mktChannelRepository;

    /**
     * 查询市场渠道管理

     * @param request
     * @return 市场渠道管理
 分页集合
     * */
    @Override
    public PageResponse<MktChannel> page(MktChannelRequest request)
    {
        LambdaQueryWrapper<MktChannel> query = new LambdaQueryWrapper<MktChannel>();
        query.eq(ObjectUtil.isNotEmpty(request.getChnType()), MktChannel::getChnType, request.getChnType());
        query.like(ObjectUtil.isNotEmpty(request.getChnName()), MktChannel::getChnName, request.getChnName());
        query.gt(ObjectUtil.isNotEmpty(request.getBeginTime()), MktChannel::getBeginTime, request.getBeginTime());
        query.lt(ObjectUtil.isNotEmpty(request.getEndTime()), MktChannel::getEndTime, request.getEndTime());
        query.eq(ObjectUtil.isNotEmpty(request.getChnTradeStatus()), MktChannel::getChnTradeStatus, request.getChnTradeStatus());
        query.eq(ObjectUtil.isNotEmpty(request.getChnHead()), MktChannel::getChnHead, request.getChnHead());
        return Pageable.of(request,(()->  mktChannelRepository.selectList(query)));
    }

    /**
     * 查询市场渠道管理

     *
     * @param id 市场渠道管理
ID
     * @return 市场渠道管理

     */
    @Override
    public MktChannel selectMktChannelById(Long id)
    {
        return mktChannelRepository.selectById(id);
    }

}
